
from Huice import hc, func
import datetime#获取更毫秒级时间
import numpy as np
import matplotlib.pyplot as plt#约定俗成的写法plt

if __name__ == '__main__':
    bcsj = int(datetime.datetime.now().strftime('%H%M%S%f'))
    fun = func.BasicStatsOpe() # 初始化函数计算实例
    help(hc.HuiCe)  # 查看回测使用方法
    df = -hc.Return(hc.Loddata('close_60m')[0:], 1)  # 读取60分钟数据的收盘价矩阵表，并计算收益率，
    #df = -fun.Skew(hc.Loddata('close_60m')[0:], 6)
    #df = fun.DECAY_LINEAR(df, 6)
    # df[df >= 0] = 1
    # df[df <= 0] = -1
    nianshouyi, meirileijishouyi= hc.HuiCe(df,60, 0) # 默认的输出每行元素的索引值。这些索引值对应的元素是从小到大排序的df[5000:, :]
    print('运行耗时===', int(datetime.datetime.now().strftime('%H%M%S%f')) - bcsj)
    meirileijishouyi.plot()
    plt.show()

    ## 下面为常用计算函数
    x = func.BasicStatsOpe() # 初始化函数计算实例
    #print(x.abs(df))
    #print(x.MovAvg(df,param=10))
    #print(x.Correlation(df,df_high,10))
    #print(x.Correlation(df,df_high,10))
    #print(x.DECAY_LINEAR(df,10))
    #print(x.MAX(df,10).shape)
    #print(x.product(df,step=5))
    #print(x.STDDEV(df,10))
    #print(x.Return(df))
    #print(x.Skew(df_high,param=10).shape)
    #print(x.ATR(df,df_high,df_low,param=16))
